package com.qf.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.TaxReturn;
import com.qf.entity.TotalSales;
import com.qf.service.TaxReturnService;
import com.qf.service.TotalSalesService;
import com.qf.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/tax/tax1")
public class TaxReturnController {

    @Autowired
    private TaxReturnService service;

    /*查询全部*/
    @GetMapping("/list")
    public R findAll(@RequestParam HashMap<String,String> map){
        int pageNum = Integer.parseInt(map.get("pageNum"));
        int pageSize = Integer.parseInt(map.get("pageSize"));
        PageHelper.startPage(pageNum,pageSize);

        List<TaxReturn> list = service.findAll(map);
        PageInfo<TaxReturn> info = new PageInfo<>(list);
        return R.ok(info);
    }




    /*通过id删除*/
    @GetMapping("/del")
    public R deleteById(int id) {
        boolean isok = service.deleteById(id);
        System.out.println(isok);

        return R.ok(isok);
    }

    /*批量删除*/
    @GetMapping("/delBatch")
    public R delBatch(@RequestParam List<Integer> ids){
        boolean isok = service.delBatch(ids);
        System.out.println("TotalSalesController.delBatch,接收到的ids = " +ids );
        return R.ok(isok);
    }

    /*添加*/
    @PostMapping("/add")
    public R addTaxRetur(@RequestBody TaxReturn taxReturn) {
        boolean isok = service.addTaxReturn(taxReturn);

        return R.ok(isok);
    }

    /*更正*/
    @PostMapping("/change")
    public R change(@RequestBody TaxReturn taxReturn) {
        boolean isok = service.change(taxReturn);
        return R.ok(isok);
    }
}
